package population.populationFindPredicates;

import java.util.Random;

import character.Character;

/**
 * Find random characters.
 * @author pcdejager
 */
public class FindRandom implements PopulationFindPredicate {
    /**
     * Constructor.
     * @param prob The probability
     */
    public FindRandom(final double prob) {
        probability = prob;
        random = new Random();
    }

    /**
     * Check function.
     * @param c The character to check
     * @return True if random chance triggered, else false
     */
    public final boolean check(final Character c) {
        if (random.nextDouble() <= probability) {
            return true;
        }
        return false;
    }

    /**
     * The probability to use.
     */
    private double probability = 0.0;
    /**
     * The random generator to use.
     */
    private Random random = null;
}
